org 0x8000


    dw 0x55aa
    mov ax, cs
    mov ds, ax
    mov es, ax
    mov ss, ax
    mov sp, 0x7c00
    

    mov si,msg

    call print
    
    call GetVBEControlerInfo
    call break
    call testVBERetStatus
    cmp  ax,0x0
    jz getVbeControlerInfoFail
    call getModeInfo

    jmp $





getModeInfo:
    mov ax, 4F01h ; VBE function 4F01h
    mov di, 0x9800 ; pointer to mode info buffer
    mov cx, 0x180 ; mode number
    int 10h ; call BIOS video services
    ret




GetVBEControlerInfo:
    mov ax, 0x4F00       ; 设置VBE功能号为0x4F00
    mov di, 0x9000         ; 设置ES:DI指向VBE信息块
    int 0x10             ; 调用BIOS中断0x10，执行VBE功能
    ret                  ; 返回

testVBERetStatus:
    mov [vbeRetStatus],ax
    cmp ax, 0x4f
    mov ax, 0x0
    jnz .getVBEStatusDone
    mov ax, 0x1
.getVBEStatusDone:
    ret

getVbeControlerInfoFail:
    mov si,msg_GetInfoError
    call print 
    jmp $

print:
    mov ah,0x0e
.next:
    mov al,[si]
    cmp al,0
    jz .done
    int 0x10
    inc si
    jmp .next
.done:
    ret

break:
    xchg bx,bx
    ret

    msg db "start loader",10,13,0

    msg_GetInfoError: db "vbe status fail!",10,13,0


    vbeRetStatus: dw 0x0000



